import Vue from 'vue'
import Router from 'vue-router';
//import Antd from 'ant-design-vue';
import {Badge,Calendar,Checkbox,Collapse,InputNumber,Upload,TreeSelect,Tooltip,Row,Col,Breadcrumb,Popconfirm,Tree,LocaleProvider,Layout,Icon,Form,Menu,Avatar,Dropdown,Button,Input,Select,Table,DatePicker,Tabs,Card,Radio,Message,Modal,List,Progress, 
Steps,
} from 'ant-design-vue'
//import Layout from 'ant-design-vue/lib/layout'
//import "ant-design-vue/dist/antd.css";
import 'ant-design-vue/dist/antd.less'
import router from './router'
import store from './store'
import App from './App'
import  {http}  from './api';
import VueWechatTitle from 'vue-wechat-title'
import Echarts from 'echarts'
//import VueClipboard from 'vue-clipboard2'
let components = [Badge,Calendar,Checkbox,Collapse,InputNumber,Upload,TreeSelect,Tooltip,Row,Col,Breadcrumb,Popconfirm,Tree,LocaleProvider,Layout,Icon,Form,Menu,Avatar,Dropdown,Button,Input,Select,Table,DatePicker,Tabs,Card,Radio,Message,Modal,List,Progress, Steps]
components.forEach(c=>{
	Vue.use(c);
})

//Vue.use(VueClipboard)
Vue.prototype.$echarts = Echarts
Vue.use(VueWechatTitle)
Vue.config.productionTip = false

//定义focus事件
Vue.directive('focus', {
	bind: function (el) {
		el.focus()
	}
});

Vue.use(Router);
const getMenus = (arr)=>{
	// let menus = []
	// arr.forEach(v=>{
	// 	menus.push(v.url)
	// 	if(v.children.length >0){
	// 		menus=menus.concat(getMenus(v.children))
	// 	}
	// })
	return arr
}
/*****防止刷新页面store数据丢失****/
let userinfo = localStorage.getItem('user_info')
//let menurole = localStorage.getItem('dispatch_role')
if(userinfo && store.getters.token ==undefined){
	let user_arr = JSON.parse(userinfo)
    store.dispatch('SetUserInfo',user_arr)
	Vue.prototype.is_admin = user_arr.is_admin

	Vue.prototype.menu_role = getMenus(user_arr.menu)
}
/* if(menurole){
	let role_arr = JSON.parse(menurole)
	Vue.prototype.menu_role = role_arr
} */
Vue.prototype.setadmin = (is_admin)=>{Vue.prototype.is_admin = is_admin};
Vue.prototype.setRole = (arr)=>{Vue.prototype.menu_role = arr};
Vue.prototype.http = http;
Vue.prototype.$message = Message;
Vue.prototype.$confirm = Modal.confirm;
Vue.prototype.$success = Modal.success;


new Vue({
	store,
  router,
  render: h => h(App),
}).$mount('#app')
